package WaiBao;

import java.util.Arrays;

public class XiongWenHao {
    public static void main(String[] args) {
        String[] name = {"李凯凯(班长)", "彭颖(纪律委员)", "小李(学习委员)", "康壮(体育委员)", "张艳军", "白敬亭", "王晓伟", "赵则好", "李康", "李香甜","李旺", "韩静",
                "季昌明", "杜牧", "支付宝", "许嵩", "徐良", "吴磊", "李存勖", "李星云", "李柒", "王自力", "王杰鹏", "武大郎", "马锦旗", "王朝阳", "雷富贵", "西孟庆",
                "潘金莲", "熊文浩(学生)"};//考生本人:熊文浩(学生)
        int[] age = {20, 21, 21, 22, 19, 20, 19, 21, 20, 20, 18, 18, 18, 20, 21, 19, 20, 18, 20, 21, 20, 19, 21, 20, 20, 19, 20, 21,20, 19};//考生年龄：19

        double[] jishu1 = {84, 72, 76, 74, 97, 70, 77, 82, 81, 91, 91, 87, 85, 69, 67, 68, 69, 79, 90, 84, 92, 91, 95, 65, 75, 76, 95, 79, 68, 96};
        double[] jishu2 = {75, 67, 85, 76, 85, 64, 68, 64, 74, 85, 72, 77, 64, 84, 85, 65, 76, 69, 76, 98, 72, 71, 95, 85, 74, 85, 84, 64, 76, 96};
        double[] jishu3 = {79, 69, 82, 85, 75, 64, 73, 69, 80, 80, 93, 87, 85, 65, 69, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 86, 77, 74, 85, 95};


        double yangyang1 ;//代表每个学生的总分
        double yangyang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            yangyang1 = xianyu1[i] +xianyu2[i] +xianyu3[i];
//            yangyang2 = (yangyang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + yangyang1);
//            System.out.println(name[i] + "的平均分为:" + yangyang2);
//        }



        double yingyue1 = 0, yingyue2 = 0;
        double[] wangyi = new double[30];
//        for (int i = 0; i < 30; i++) {
//            yingyue1= jishu1[i] + jishu2[i] +jishu3[i];
//            yingyue2 = (yingyue1* 1.0) / 3;
//            wangyi[i] = yingyue2;
//        }
//
//        for (int i = 0; i < wangyi.length - 1; i++) {
//            for (int j = 0; j <  wangyi.length - i - 1; j++) {
//                if (wangyi[j] <wangyi[j + 1]) {
//                    double tep =wangyi[j];
//                    wangyi[j] = wangyi[j + 1];
//                    wangyi[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(wangyi[i]);
//        }


        double hefei1 = 0,  hefei2 = 0, hefei3 = 0;//计算每门课的平均分
        double luan1 = 0, luan2 = 0, luan3 = 0;//计算每门课标准差
        double wuhu1 = 0,wuhu2 = 0, wuhu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < jishu1.length; i++) {
            he += jishu1[i];
        }
        hefei1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +hefei1);
        double Sum = 0;
        for (int i = 0; i <jishu2.length; i++) {
            Sum +=jishu2[i];
        }
        hefei2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +  hefei2);
        double sum = 0;
        for (int i = 0; i <jishu3.length; i++) {
            sum +=jishu3[i];
        }
        hefei3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +  hefei3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <jishu1.length; i++) {
            c1 += (jishu1[i] - hefei1) * (jishu1[i] - hefei1);
        }
        luan1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +luan1);
        for (int i = 0; i <jishu2.length; i++) {
            c2 += (jishu2[i] - hefei2) * (jishu2[i] - hefei2);
        }
        luan2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +luan2);

        for (int i = 0; i <jishu3.length; i++) {
            c3 += (jishu3[i] -hefei3) * (jishu3[i] - hefei3);
        }
        luan3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + luan3);
////////////
        Arrays.sort(jishu1);
        Arrays.sort(jishu2);
        Arrays.sort(jishu3);
        wuhu1 = (jishu1[15] + jishu2[14]) * 1.0 / 2;
        wuhu2 = (jishu2[15] + jishu2[14]) * 1.0 / 2;
        wuhu3 = (jishu3[15] + jishu3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + wuhu1);
        System.out.println("农业设施设计与制造的中位数为:" + wuhu2);
        System.out.println("园艺植物设施栽培学的中位数为:" + wuhu3);

    }
}
